#pragma once
#include "SAbstractChartView.h"
#include "../model/SColumnChartData.h"

SNSBEGIN

// Forward declarations
class SColumnChartRenderer;

/**
 * @class SColumnChartView
 * @brief Column chart view implementation
 */
class SColumnChartView : public SAbstractChartView
{
    DEF_SOBJECT(SAbstractChartView, L"columnChart")

public:
    /**
     * @brief Constructor
     */
    SColumnChartView();
    
    /**
     * @brief Destructor
     */
    virtual ~SColumnChartView();

    /**
     * @brief Get column chart data
     * @return Pointer to column chart data
     */
    SColumnChartData* GetColumnChartData() const { return m_pData; }
    
    /**
     * @brief Set column chart data
     * @param pData Pointer to column chart data
     */
    void SetColumnChartData(SColumnChartData* pData);
    
    /**
     * @brief Fire column chart value select event
     * @param columnIndex Column index
     * @param subcolumnIndex Subcolumn index
     * @param pValue Subcolumn value
     */
    void FireValueSelectEvent(int columnIndex, int subcolumnIndex, SSubcolumnValue* pValue);

    // SAbstractChartView interface
    virtual SChartData* GetChartData() OVERRIDE { return m_pData; }
    virtual void CallTouchListener() OVERRIDE;
    virtual void InitializeRenderers() OVERRIDE;
    virtual void WINAPI OnInitFinished(IXmlNode* xmlNode) OVERRIDE;

    // SOUI attributes
    SOUI_ATTRS_BEGIN()
        ATTR_BOOL(L"stacked", m_bStacked, TRUE)
        ATTR_FLOAT(L"fillRatio", m_fillRatio, TRUE)
    SOUI_ATTRS_END()

protected:
    /**
     * @brief Handle value selection
     * @param columnIndex Selected column index
     * @param subcolumnIndex Selected subcolumn index
     */
    void OnValueSelected(int columnIndex, int subcolumnIndex);
    
    /**
     * @brief Handle value deselection
     */
    void OnValueDeselected();

private:
    SColumnChartData* m_pData;
    
    // Attributes
    BOOL m_bStacked;
    float m_fillRatio;
};

SNSEND
